package cn.mumzone.pos.presenter;


import java.util.List;

import cn.mumzone.basic.mvp.AbsPresenter;
import cn.mumzone.basic.net.http.callback.ApiCallBack;
import cn.mumzone.basic.net.response.BaseResponse;
import cn.mumzone.pos.model.GoodsClassifyEntity;
import cn.mumzone.pos.model.SalesVolumeEntity;
import cn.mumzone.pos.model.source.ReportRepository;
import cn.mumzone.pos.presenter.contract.SalesVolumeReportContract;

/**
 * Created by qiuzhenhuan on 2019/3/22.
 */

public class SalesVolumeReportPresenter extends AbsPresenter<SalesVolumeReportContract.View, ReportRepository> implements SalesVolumeReportContract.Presenter {


    @Override
    public void requestSalesVolume(String time, String classifyOne, String classifyTwo, String classifyThree, String orderType) {
        mView.showLoadingDialog();
        ApiCallBack<List<SalesVolumeEntity>> callBack = new ApiCallBack<List<SalesVolumeEntity>>() {
            @Override
            public void onSuccess(List<SalesVolumeEntity> list) {
                mView.showSalesVolume(list);
                mView.dismissLoadingDialog();
            }

            @Override
            public void onError(BaseResponse response) {
                mView.dismissLoadingDialog();
                mView.showError(response.getMsg());
            }
        };

        mRepo.getSalesVolumeReportByDate(time, classifyOne, classifyTwo, classifyThree, orderType, callBack);
        addSubscrebe(callBack);
    }

    @Override
    public void requestGoodsClassify(String classifyOne, String classifyTwo, String classifyThree) {
        mView.showLoadingDialog();
        ApiCallBack<List<GoodsClassifyEntity>> callBack = new ApiCallBack<List<GoodsClassifyEntity>>() {
            @Override
            public void onSuccess(List<GoodsClassifyEntity> classifyEntities) {
                mView.dismissLoadingDialog();
                mView.showGoodsClassify(classifyEntities);
            }

            @Override
            public void onError(BaseResponse response) {
                mView.dismissLoadingDialog();
                mView.showError(response.getMsg());
            }
        };
        mRepo.getGoodsClassify(classifyOne, classifyTwo, classifyThree, callBack);
        addSubscrebe(callBack);
    }
}
